//////////////////////////////////////////////////////////////////////////
//
// GAM203
// Quad class
// Quad.h
// 
// Grant Johnson
// Qantm College
// 27/10/2010
//
//////////////////////////////////////////////////////////////////////////

#ifndef QUAD_H
#define QUAD_H

#include "Drawable.h"

class Quad : public Drawable
{
public:
	// Vertex format we will use to describe our vertices (must match FVF format below)
	struct VertexData
	{
		D3DVECTOR pos;
		D3DVECTOR normal;
		float u,v;
	};

	// DirectX's way of identifying what's in our vertex structure (we bitwise OR these values)
	static const DWORD VERTEX_FORMAT_FVF = D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1;
	
	Quad();
	virtual ~Quad();

	//////////////////////////////////////////////////////////////////////////
	// VIRTUAL - Inherited from Drawable
	// For creating the drawable object
	//
	// Paramaters:
	// a_pDevice, the direct3d device
	// a_pTexFileName, a path passed into the function. This can either be used for
	// the texture file name, or for a mesh's file name.
	//
	// Returns false if any step of the creation failed
	// Returns true if created successfully
	//
	//////////////////////////////////////////////////////////////////////////
	virtual bool CreateObject(IDirect3DDevice9* a_pDevice, char* a_pTexFileName);

	//////////////////////////////////////////////////////////////////////////
	// VIRTUAL - Inherited from Drawable
	// For rendering the drawable object
	//
	// Paramaters:
	// a_pDevice, the direct3d device
	//
	// Returns void
	//
	//////////////////////////////////////////////////////////////////////////
	virtual void Render(float a_dt, IDirect3DDevice9* a_pDevice, const RenderParams& a_renderParams);

	ID3DXMesh* GetMesh() const { return m_pMesh; }


private:
	//Filename of the texture to apply to the drawable object
	char* m_pTexFilename;
	
	//Direct3D texture pointer
	IDirect3DTexture9* m_pTex;

	ID3DXMesh* m_pMesh;

	D3DMATERIAL9 m_mtl;

	//Store vertex and index data
	VertexData* m_pVertData;
	unsigned short* m_pIndexData;

	//Store the number of vertices, indices and primitives
	long m_vertCount;
	long m_indexCount;
};

#endif

